#ifndef EXPERIMENTMETHODUI_H
#define EXPERIMENTMETHODUI_H

#include <QAction>
#include <QLabel>
#include <QMenu>
#include <QMessageBox>
#include <QSpacerItem>
#include <QScrollBar>
#include <QWidget>

#include "global.h"
#include "methodmovebutton.h"
#include "ProcedureService.h"
#include "QPCRDB.h"
#include "stagestep.h"
#include "UiStruct.h"
#include "custommessagebox.h"

namespace Ui {
class ExperimentMethodUi;
}

class ExperimentMethodUi : public QWidget
{
    Q_OBJECT

public:
    explicit ExperimentMethodUi(QWidget *parent = nullptr);
    ~ExperimentMethodUi();

private:
    Ui::ExperimentMethodUi *ui;

signals:
    void sendTotalCycling(int cycling); // 发送循环数
    void previousEvent();
    void nextEvent();
    void saveEvent();
    void sigChangeMethodWaveCascade();

public slots:
    void nextCallback(); // 下一步

public:
    bool allMarkedStatus();
    void getMethodData(QString id, QString experimentType);
    void renderProcedure(QString);
    std::tuple<int, int, int, int, int> returnPageInfos(); // 返回数据信息
    void allComponentsInvalid(); // 所有组件失效
    void allComponentsValid(); // 所有组件生效

protected:
    void resizeEvent(QResizeEvent *event);

public:
    int totalrunningTime;

private:
    /* 常量定义和初始化 */
    const double SLIDER_HANDLER_HEIGHT = 17.5; // 滑块高度
    const double SLIDER_INIT_HEIGHT = 7; // 滑动条初始值液面高度

    CustomMessageBox *cusMsg;
    int procedureScrollBarValue;
    int PcrStepCount;
    int stageCount;
    int stepCount;
    int runningMinute;
    int runningSecond;
    int cyclingNumber;
    ProcedureService *procedureService;
    QList<QHash<QString,QString>> stageList;
    QHash<QHash<QString,QString>,QList<QHash<QString,QString>>> procedureList;
    QSpacerItem *hSpacer;
    QString id;
    QString experimentType;
    QTimer *arrEventTimer1;
    QTimer *arrEventTimer2;

private:
    std::tuple<QHBoxLayout*, QWidget*, QString> createNewStage(QString, QString, QString, QString, QString);
    void createStep(QHBoxLayout*, ProcedureStep, QString, QString);
    void resetProcedure(QString);
    void viaTempMinusToCalculateTime();
    void sleep(int msec);

};

#endif // EXPERIMENTMETHODUI_H
